<?php

// define paths
define('APP', __DIR__.'/..');
define('APP_CONTROLLERS', APP.'/app/controllers');
define('APP_MODELS', APP.'/app/models');
define('APP_VIEWS', APP.'/app/views');
define('APP_LAYOUTS', APP.'/app/views/layouts');
define('APP_CONFIG', APP.'/config');
define('APP_DB', APP.'/db');
define('APP_DOC', APP.'/doc');
define('APP_LIB', APP.'/lib');
define('APP_LOG', APP.'/log');
define('APP_PUBLIC', APP.'/public');
define('APP_SCRIPTS', APP.'/scripts');
define('APP_TASKS', APP.'/tasks');
define('APP_TMP', APP.'/tmp');
define('APP_VENDOR', APP.'/vendor');
define('APP_PLUGINS', APP.'/vendor/plugins');

// load base config
require(APP_CONFIG.'/environment.php');

app_initialize();

// initilizing app
function app_initialize() {

    // load mini initialization script
    require(PATH_TO_MINI.'/mini.php');

    // load envionment file
    $environment = Configuration::get('environment', MINI_APP_ENVIRONMENT);
    require(APP_CONFIG.DS.'environments'.DS.$environment.'.php');

    // set logging target
    ini_set('error_log', APP_LOG.DS.$environment.'.log');

    // load Routes
    require(APP_CONFIG.DS.'routes.php');

    // load the init.php
    require(APP_CONFIG.DS.'init.php');
}
